<link rel="stylesheet" href="{{ asset('bundles/rtscraftmain/css/article.css') }}" type="text/css" media="all" />

<center>
{% if entity != null %}
<!-- The header of the element. -->
{% block introduction %}
<table width=60%>
  <tr><th colspan="3" class="entity_name">
      {{ entity.name }}
  </th></tr>
  {% for faction in entity.factions %}
  <tr>
    <!--Fixme : include image ?-->
    <td width=25px>
      <form name="action_form" method="post" action="{{ path('_entity_data_del') }}">
	<input name="action_type" type="hidden" value="faction"/>
	<input name="action_value" type="hidden" value="{{faction.name }}"/>
	<input name="action_entity" type="hidden" value="{{ entity.name }}"/>	
	<input type="submit" value="-"/>
	</form>
    </td>
    <td>
      <center>
	{{ faction.name }}
      </center>
    </td>
  </tr>
  {% endfor %}
  <tr>
    <td colspan=3>
      <form name="action_form" method="post" action="{{ path('_entity_data_add') }}">
	<select name="action_select">
	  {% for fact in factions %}
	  <option value="{{ fact.name }}">{{ fact.name }}</option>
	  {% endfor %}
	</select>
	<input name="action_type" type="hidden" value="faction"/>
	<input name="action_entity" type="hidden" value="{{ entity.name }}"/>
	<input type=submit value="+"/>
      </form>
  </tr>

</table>
{% endblock %}

<hr/>

<!-- The resources -->
{% block ressources %}
{%   for value in entity.costs %}
{%     if value != null %}

<!-- First : the list of Costs -->
  <table width="95%">
  <tr><th colspan="3" class="entity_name">{{ value.name }}</th></tr>
    {%     for svalue in value.prices %}
    <!-- Then : the list of prices in this cost. -->
    <tr>
      <td width=25px>
	<form name="action_form" method="post" action="{{ path('_entity_data_del') }}">
	  <input name="action_type" type="hidden" value="resource"/>
	  <input name="action_value" type="hidden" value="{{ svalue.ressource.name }}"/>
	  <input name="action_entity" type="hidden" value="{{ entity.name }}"/>	
	  <input type="submit" value="-"/>
	</form>
      </td>
      <td class="statName">{{ svalue.ressource.name }}</td>
      <td class="statValue">{{ svalue.value }}</td>
    </tr>
    {%     endfor %}
  <tr>
    <td colspan=3>
      <form name="action_form" method="post" action="{{ path('_entity_data_add') }}">
	<select name="action_select">
	  {% for res in resources %}
	  <option value="{{ res.name }}">{{ res.name }}</option>
	  {% endfor %}
	</select>
	<input name="field" style="width: 50px" type="number"/>
	<input name="action_type" type="hidden" value="resource"/>
	<input name="action_entity" type="hidden" value="{{ entity.name }}"/>
	<input type=submit value="+"/>
      </form>
  </tr>
  </table>

{%     endif %}
{%   endfor %}
{% endblock %}

<hr/>

<!-- The image -->
{% block image %}
<img src={{ entity.imgURL }} alt="Click to add image !"
     class="entity_img"/>
<form name="action_form" method="post" action="{{ path('_entity_data_add') }}">
  <input name="field" type="text"/>
  <input name="action_type" type="hidden" value="image"/>
  <input name="action_entity" type="hidden" value="{{ entity.name }}"/>
  <input type=submit value="Change image"/>
</form>
{% endblock %}

<hr/>

<!-- The statistics -->
{% block statistics %}
<table width=95%>
  <tr><th colspan="3" class="entity_name">Statistics</th></tr>
  {% for sheet in entity.sheets %}
  {%  for stat in sheet.statistics %}
  <tr>
    <td width=25px>
      <form name="action_form" method="post" action="{{ path('_entity_data_del') }}">
	<input name="action_type" type="hidden" value="statistic"/>
	<input name="action_value" type="hidden" value="{{ stat.name }}"/>
	<input name="action_entity" type="hidden" value="{{ entity.name }}"/>	
	<input type="submit" value="-"/>
      </form>
    </td>

    <td class="statName">{{ stat.name }}</td> <!-- Fixme : img -->
    <td class="statValue">{{ sheet.value }}</td>
  </tr>
  {%  endfor %}
  {% endfor %}
  <tr>
    <td colspan=3>
      <form name="action_form" method="post" action="{{ path('_entity_data_add') }}">
	<select name="action_select">
	  {% for stat in statistics %}
	  <option value="{{ stat.name }}">{{ stat.name }}</option>
	  {% endfor %}
	</select>
	<input name="field" style="width: 50px" type="number"/>
	<input name="action_type" type="hidden" value="statistic"/>
	<input name="action_entity" type="hidden" value="{{ entity.name }}"/>
	<input type=submit value="+"/>
      </form>
  </tr>
</table>
{% endblock %}

{% else %}

<p>
  Select an element by clicking on it.
</p>

{% endif %}
</center>
